package com.oa.srms.apps.dao.goods.impl;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.oa.srms.apps.dao.goods.IGoodForCategoryDao;
import com.oa.srms.apps.entity.goods.GoodForCategoryValue;

public class GoodForCategoryDaoImpl extends HibernateDaoSupport implements IGoodForCategoryDao {

	@Override
	public boolean addOrModifyGoodForCategory(
			GoodForCategoryValue goodForCategory) throws Exception {
		if(goodForCategory != null){
			try{
				this.getHibernateTemplate().saveOrUpdate(goodForCategory);
			}catch(Exception e){
				return false;
			}
			return true;
		}
		return false;
	}

	@Override
	public GoodForCategoryValue queryByCategoryId(
			GoodForCategoryValue goodForCategory) throws Exception {
		if(goodForCategory != null){
			return (GoodForCategoryValue) this.getHibernateTemplate().get(GoodForCategoryValue.class, goodForCategory.getCategoryId());
		}
		return null;
	}

}
